def even_odd_times(lst):
    """
    只有一个数出现了奇数次，找出来. (异或运算)
    :param lst:
    :return:
    """
    res = 0
    for num in lst:
        res ^= num

    return res


def even_odd_times1(lst):
    """
    只有两个数出现了奇数次，找出来
    :param lst:
    :return:
    """
    tmp = 0
    for num in lst:
        tmp ^= num
    # 找最右侧的1
    rightone = tmp & (~tmp + 1)
    res1 = 0
    for num in lst:
        if (num & rightone) == 0:
            res1 ^= num

    return res1, res1 ^ tmp


if __name__ == "__main__":
    lst = [10, 10, 7, 2, 5, 5, 8, 8]
    print(even_odd_times1(lst))
